#!/usr/bin/env perl

use strict;

BEGIN {
	if(!exists($::ENV{LINUXHA_LIBS})) {
		$::ENV{LINUXHA_LIBS}="/opt/linuxha14/lib/perl";
	}
	push @INC,$::ENV{LINUXHA_LIBS};
}

# eval 'use libping6;';
# if($@) {
	# print STDERR "Failed to load libping6: $@\n"; exit(1);
# }
# 
# print "Loaded libping6 ok...\n";

eval 'use cld_client;';
if($@) {
	print STDERR "Failed to load cld_client: $@\n"; exit(1);
}

my $client=cld_client->new(PORT=>12345,KEY=>"mytestkey",TYPE=>6,INET=>"::1",ILIST=>"IP6|::1");
if(!defined($client)) {
	print STTDERR "Failed to create client to connect via port 12345\n"; exit(1);
}

# Let us send a message and show a response...

my $result=$client->send_msg(MSG=>"Hello you");
if(!defined($result)) {
	my ($a,$b)=$client->get_error();
	print STDERR "Error: $a [rc=$b]\n";
	exit 1;
}
print "Response from server: $result\n";

# Force the server to quit...
my $result=$client->send_msg(MSG=>"QUIT!");
if(!defined($result)) {
	print STDERR "Error - failed to get message from server.\n";exit(1);
}
print "Response from server: $result\n";


